package com.ruoyi.hqfinance.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.hqfinance.domain.HqBaoGanSettleSheetAdjustDaily;
import com.ruoyi.hqfinance.domain.HqBaoGanSettleSheetAdjustMonth;
import com.ruoyi.hqfinance.domain.HqBaoGanSettleSheetDayBackwash;
import com.ruoyi.hqfinance.domain.HqBaoGanSettleSheetPreDaily;
import com.ruoyi.hqfinance.domain.vo.HqBaoGanSettleSheetVo;
import com.ruoyi.hqfinance.service.HqBaoGanSettleSheetService;
import com.ruoyi.logistic.domain.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/hq/baoGanSettleSheet")
@Api(tags = "总部财务-包干结算报表")
public class HqBaoGanSettleSheetController {
    @Autowired
    private HqBaoGanSettleSheetService hqBaoGanSettleSheetService;

    @ApiOperation("包干费日预收")
    @PostMapping("/dayPre")
    public R collectByDayPre(@RequestBody HqBaoGanSettleSheetVo vo) {
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null || vo.getTimeType() == null) {
            return R.fail("请输入必要的查询条件！");
        }
        List<HqBaoGanSettleSheetPreDaily> preDailyList = hqBaoGanSettleSheetService.collectByDayPre(vo);
        if (preDailyList == null || preDailyList.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(preDailyList));
        }
    }
    @ApiOperation("包干费日调整")
    @PostMapping("/dayAdjust")
    public R collectByDayAdjust(@RequestBody HqBaoGanSettleSheetVo vo) {
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null || vo.getTimeType() == null) {
            return R.fail("请输入必要的查询条件！");
        }
        List<HqBaoGanSettleSheetAdjustDaily> adjustDailies = hqBaoGanSettleSheetService.collectAdjustDaily(vo);
        if (adjustDailies == null || adjustDailies.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(adjustDailies));
        }
    }

    @ApiOperation("包干费月调整")
    @PostMapping("/monthAdjust")
    public R collectAdjustMonth(@RequestBody HqBaoGanSettleSheetVo vo) {
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null ) {
            return R.fail("请输入必要的查询条件！");
        }
        List<HqBaoGanSettleSheetAdjustMonth> adjustMonths = hqBaoGanSettleSheetService.collectAdjustMonth(vo);
        if (adjustMonths == null || adjustMonths.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(adjustMonths));
        }
    }

    @ApiOperation("日回冲")
    @PostMapping("/backwash")
    public R collectBackwash(@RequestBody HqBaoGanSettleSheetVo vo) {
        if (vo.getStartTime() == null || vo.getEndTime() == null || vo.getNetworkNameId() == null ) {
            return R.fail("请输入必要的查询条件！");
        }
        List<HqBaoGanSettleSheetDayBackwash> backwashes = hqBaoGanSettleSheetService.collectBackwash(vo);
        if (backwashes == null || backwashes.size() == 0) {
            return R.fail("暂无数据");
        } else {
            return R.ok(PageInfo.info(backwashes));
        }
    }
}